/*
 * This file is part of aKoustiK.

 * aKoustiK is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * aKoustiK is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with aKoustiK.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <kore.h>
#include <ui/player/playlistitemdelegate.h>

PlaylistItemDelegate::PlaylistItemDelegate(QObject *parent) : QStyledItemDelegate(parent) {
    player = Kore::instance().player();
}

PlaylistItemDelegate::~PlaylistItemDelegate() {
}

void PlaylistItemDelegate::initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const {
    QStyledItemDelegate::initStyleOption(option, index);
    if (index.row() == player->current()) {
        option->font.setBold(true);
    }
    if (player->isGrey(index.row())) {
        option->palette.setBrush(QPalette::Text, QBrush(Qt::gray));
    }
    // TODO can't understand why it is not updated at once
}

void PlaylistItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
    // TODO use KColorScheme to get colors to paint some gradient for the current item
    QStyledItemDelegate::paint(painter, option, index);
}
